<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<style type="text/css">
img{
	display:block;
	
}
</style>
<body>
<img src='1.jpg' id='imgid'>	
</body>
<script type="text/javascript">
function show(){
	w=document.documentElement.clientWidth;
	if(w>1000){
		document.body.style.background="#00f";

	}else if(w>600){
		document.body.style.background='#0f0';

	}else{
		document.body.style.background='#f00';
	}
}	
show();
window.onresize=function(){
	show();
}



</script>
</html>